using UnityEngine;

namespace AudioStudio
{
    /// <summary>
    /// ���ش�����
    /// GameObject��Start/OnEnableʱ����enableEvent
    /// GameObject��OnDestroy/OnDisableʱ����disableEvent
    /// </summary>
    [AddComponentMenu("AudioStudio/MenuSound")]
    public class MenuSound : AudioEventHandler
    {
        public AudioEvent[] Opens;
        public AudioEvent[] Closes;
        
        new void Awake()
        {
            this.IsUpdatePosition = false;
            this.isEnvironmentAware = false;
            this.StopOnDestroy = false;
            base.Awake();
        }

        public override void HandleEnableEvent()
        {
            Post(Opens);
        }

        public override void HandleDisableEvent()
        {
            Post(Closes);
        }

        private void Post(AudioEvent[] events)
        {
            AudioManager.Instance.PostEvents(this.Player,events);
        }
    }
}
